# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
pkgname=handbrake
_pkgname=HandBrake
pkgver=1.3.3
pkgrel=0
pkgdesc="Handbrake video transcoder"
url="https://handbrake.fr"
arch="x86_64 x86 armhf armv7 ppc64le"
license="GPL-2.0-only"
makedepends="
	autoconf
	automake
	cmake
	coreutils
	dav1d-dev
	dbus-glib-dev
	fdk-aac-dev
	ffmpeg-dev
	fontconfig-dev
	freetype-dev
	fribidi-dev
	glib-dev
	gst-plugins-base-dev
	gtk+3.0-dev
	intltool
	jansson-dev
	lame-dev
	libass-dev
	libbluray-dev
	libbz2
	libdvdnav-dev
	libdvdread-dev
	libgudev-dev
	libnotify-dev
	libogg-dev
	libtheora-dev
	libtool
	libvorbis-dev
	libvpx-dev
	linux-headers
	meson
	nasm
	opus-dev
	python3
	speex-dev
	tinyxml-dev
	x264-dev
	xz-dev
	yasm
	zlib-dev
	"
subpackages="$pkgname-lang $pkgname-gtk"
source="https://github.com/HandBrake/HandBrake/releases/download/$pkgver/HandBrake-$pkgver-source.tar.bz2
	handbrake-9999-remove-dvdnav-dup.patch
	handbrake-9999-remove-faac-dependency.patch
	"
options="!check"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare
	# build against external libs
	sed -i 's:.*contrib/.*::g' \
		make/include/main.defs
}

build() {
	./configure \
		--prefix=/usr \
		--force \
		--verbose \
		--disable-nvenc \
		--disable-numa \
		--disable-x265 \
		--disable-gtk-update-checks

	cd build
	make
}

package() {
	cd "$builddir"/build
	make -j1 install DESTDIR="$pkgdir"
}

gtk() {
	pkgdesc="HandBrake Video Transcoder - GUI"
	install -d "$subpkgdir"/usr/bin

	mv "$pkgdir"/usr/bin/ghb "$subpkgdir"/usr/bin/ghb
	mv "$pkgdir"/usr/share "$subpkgdir"/usr

}

sha512sums="a4cca4e45d39eb3d43441abe832e2b8398694917981fa994075e475b68297cae28039e3c75d06442194262a881b9e416e5ebd73d10f86214b95f54c35fd3088c  HandBrake-1.3.3-source.tar.bz2
a3d57dd37d518286a62554cfcc4722d6fd588a0c3966d30785100edc4476febb2b48fc4f9b2a7eb5b5dc049043fabd4398e1e190e10cbd63c25b2936824977d3  handbrake-9999-remove-dvdnav-dup.patch
9d070e50a9b7d4b8ac25b7d56bd341aca6dc979ba506c84f4b95109909f70020723915cd120bed24e84a8fc242ee3c3a5775f43a78b7995e53cd499444c9f6dc  handbrake-9999-remove-faac-dependency.patch"
